import Vue from 'vue'
import Router from 'vue-router'
// 引入首页根组件
import Home from "@/pages/home/Home"
// 引入列表页根组件
import List from '@/pages/list/List'
// 引入我的页面根组件
import Mine from '@/pages/mine/Mine.vue'
// 引入404页面根组件
import Error from '@/pages/404/404.vue'
// 引入搜索页面根组件
import Search from '@/pages/search/Search'
// 引入我的账户页面根组件
import Account from '@/pages/account/Account'
// 引入登录页面根组件
import Login from '@/pages/login/Login'
// 引入收藏页面根组件
import Collect from '@/pages/collect/Collect'
// 引入商品页面根组件
import Goods from '@/pages/goods/Goods'
// 引入支付页面根组件
import Order from '@/pages/order/Order.vue'

Vue.use(Router)

export default new Router({
  routes: [
    {
        path: '/',
        redirect: '/home'//当访问根路径/的时候，使用redirect重定向到首页/home
      },
    {
      path: '/home',
      name: 'Home',
      component: Home
    },
    {
        path: '/list',
        name: 'List',
        component: List
      },
      {
        path: '/mine',
        name: 'Mine',
        component: Mine
      },
      {
        path: '/search',
        name: 'Search',
        component: Search
      },
      {
        path: '/account',
        name: 'Account',
        component: Account
      },
      {
        path: '/login',
        name: 'Login',
        component: Login
      },
      {
        path: '/collect',
        name: 'Collect',
        component: Collect
      },
      {
        path: '/goods',
        name: 'Goods',
        component: Goods
      },
      {
        path: '/order',
        name: 'Order',
        component: Order
      },
      {
        path: '/error',
        name: 'Error',
        component: Error
      },
      {
        path: '/*',
        redirect: '/error'//当访问路径不存在时，使用redirect重定向到首页/home
      }
  ]
})
